{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "-"
    }
   },
   "source": [
    "# API文档\n",
    "- 地理/逆地理编码\n",
    "- 路径规划\n",
    "- 行政区域查询\n",
    "- 搜索POI\n",
    "- IP定位\n",
    "- 批量请求接口\n",
    "- 静态地图坐标转换\n",
    "- 天气查询\n",
    "- 输入提示\n",
    "- 交通态势\n",
    "- 地理围栏\n",
    "- 轨迹纠偏"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 地理编码与逆地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "div.code_cell {\n",
       "    background-color: #e5f1fe;\n",
       "}\n",
       "div.cell.selected {\n",
       "    background-color: #effee2;\n",
       "    font-size: 2rem;\n",
       "    line-height: 2.4rem;\n",
       "}\n",
       "div.cell.selected .rendered_html table {\n",
       "    font-size: 2rem !important;\n",
       "    line-height: 2.4rem !important;\n",
       "}\n",
       ".rendered_html pre code {\n",
       "    background-color: #C4E4ff;   \n",
       "    padding: 2px 25px;\n",
       "}\n",
       ".rendered_html pre {\n",
       "    background-color: #99c9ff;\n",
       "}\n",
       "div.code_cell .CodeMirror {\n",
       "    font-size: 2rem !important;\n",
       "    line-height: 2.4rem !important;\n",
       "}\n",
       ".rendered_html img, .rendered_html svg {\n",
       "    max-width: 50%;\n",
       "    height: auto;\n",
       "    float: center;\n",
       "}\n",
       "/* Gradient transparent - color - transparent */\n",
       "hr {\n",
       "    border: 0;\n",
       "    border-bottom: 1px dashed #ccc;\n",
       "}\n",
       ".emoticon{\n",
       "    font-size: 5rem;\n",
       "    line-height: 4.4rem;\n",
       "    text-align: center;\n",
       "    vertical-align: middle;\n",
       "}\n",
       "\n",
       "</style>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%html\n",
    "<style>\n",
    "div.code_cell {\n",
    "    background-color: #e5f1fe;\n",
    "}\n",
    "div.cell.selected {\n",
    "    background-color: #effee2;\n",
    "    font-size: 2rem;\n",
    "    line-height: 2.4rem;\n",
    "}\n",
    "div.cell.selected .rendered_html table {\n",
    "    font-size: 2rem !important;\n",
    "    line-height: 2.4rem !important;\n",
    "}\n",
    ".rendered_html pre code {\n",
    "    background-color: #C4E4ff;   \n",
    "    padding: 2px 25px;\n",
    "}\n",
    ".rendered_html pre {\n",
    "    background-color: #99c9ff;\n",
    "}\n",
    "div.code_cell .CodeMirror {\n",
    "    font-size: 2rem !important;\n",
    "    line-height: 2.4rem !important;\n",
    "}\n",
    ".rendered_html img, .rendered_html svg {\n",
    "    max-width: 50%;\n",
    "    height: auto;\n",
    "    float: center;\n",
    "}\n",
    "/* Gradient transparent - color - transparent */\n",
    "hr {\n",
    "    border: 0;\n",
    "    border-bottom: 1px dashed #ccc;\n",
    "}\n",
    ".emoticon{\n",
    "    font-size: 5rem;\n",
    "    line-height: 4.4rem;\n",
    "    text-align: center;\n",
    "    vertical-align: middle;\n",
    "}\n",
    "\n",
    "</style>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "key =\"00837098d93ef635613eebd34c533c33\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "113.679287,23.632575\n"
     ]
    }
   ],
   "source": [
    "def geocodes(address:str,city=None,batch=None,sig=None)-> dict:\n",
    "    \"\"\"获取地理编码\n",
    "    address可填入国家、省份、城市、区县、城镇、乡村、街道、门牌号码、屋邨、大厦等建筑物名称\n",
    "    填入address对应city即可查询具体经纬度\n",
    "    \"\"\"\n",
    "    parameters = {'key':key,\n",
    "                  'city':city,\n",
    "                  'citylimit': True,\n",
    "                  'address':address,\n",
    "                  'batch':batch,\n",
    "                  'sig':sig,\n",
    "                  'output':'json'\n",
    "                   } \n",
    "    r = requests.get (\"https://restapi.amap.com/v3/geocode/geo?parameters\", params=parameters)\n",
    "    data = r.json()['geocodes'][0]['location']\n",
    "    return data\n",
    "中大南方 = geocodes(address='广东省广州市从化区中山大学南方学院')\n",
    "print(中大南方)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'status': '1', 'regeocode': {'roads': [{'id': '020F49F0050461203', 'location': '113.68,23.634', 'direction': '南', 'name': '博学路', 'distance': '156.951'}, {'id': '020F49F0050462451', 'location': '113.677,23.6347', 'direction': '东南', 'name': '中山路', 'distance': '343.951'}, {'id': '020F49F006047765', 'location': '113.682,23.6394', 'direction': '南', 'name': 'S29从莞深高速', 'distance': '807.947'}], 'roadinters': [{'second_name': '中山路', 'first_id': '020F49F0050461203', 'second_id': '020F49F0050462451', 'location': '113.6767944,23.63466139', 'distance': '343.951', 'first_name': '博学路', 'direction': '东南'}], 'formatted_address': '广东省广州市从化区温泉镇中山大学南方学院', 'addressComponent': {'city': '广州市', 'province': '广东省', 'adcode': '440117', 'district': '从化区', 'towncode': '440117103000', 'streetNumber': {'number': '7号', 'location': '113.6786,23.6333289', 'direction': '西北', 'distance': '109.203', 'street': '博学路'}, 'country': '中国', 'township': '温泉镇', 'businessAreas': [[]], 'building': {'name': [], 'type': []}, 'neighborhood': {'name': [], 'type': []}, 'citycode': '020'}, 'aois': [{'area': '536585.849985', 'type': '141201', 'id': 'B00140MR9A', 'location': '113.679262,23.632583', 'adcode': '440117', 'name': '中山大学南方学院', 'distance': '0'}], 'pois': [{'id': 'B00140MR9A', 'direction': '西', 'businessarea': [], 'address': '温泉大道882号', 'poiweight': '0.450402', 'name': '中山大学南方学院', 'location': '113.679262,23.632583', 'distance': '2.69979', 'tel': '020-61787326;020-61787333', 'type': '科教文化服务;学校;高等院校'}, {'id': 'B0FFF2VMJ4', 'direction': '东南', 'businessarea': [], 'address': '温泉大道886号中山大学南方学院内', 'poiweight': '0.148531', 'name': '中山大学南方学院-综合楼', 'location': '113.680117,23.631544', 'distance': '142.466', 'tel': [], 'type': '科教文化服务;学校;学校'}, {'id': 'B0FFFTC9PH', 'direction': '东北', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.193172', 'name': '中山大学南方学院教学楼10号', 'location': '113.680125,23.633492', 'distance': '132.988', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B00141TQKX', 'direction': '西北', 'businessarea': [], 'address': '温泉大道882', 'poiweight': '0.148531', 'name': '中山大学南方学院教学楼6号', 'location': '113.678424,23.633710', 'distance': '153.818', 'tel': [], 'type': '科教文化服务;学校;学校'}, {'id': 'B00141WQCO', 'direction': '东北', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.14954', 'name': '中山大学南方学院教学楼8号', 'location': '113.680399,23.634329', 'distance': '225.543', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B00141TRVH', 'direction': '西南', 'businessarea': [], 'address': '博学路21', 'poiweight': '0.148531', 'name': '中山大学南方学院教学楼2号', 'location': '113.677060,23.631346', 'distance': '264.846', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B0FFKP9ET5', 'direction': '西南', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.191742', 'name': '中山大学南方学院1号实验楼', 'location': '113.678215,23.631370', 'distance': '172.86', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B00140TWHT', 'direction': '南', 'businessarea': [], 'address': '笃行路2', 'poiweight': '0.157653', 'name': '教工住宅1号', 'location': '113.678490,23.630432', 'distance': '251.758', 'tel': [], 'type': '商务住宅;住宅区;住宅小区'}, {'id': 'B0FFHC4XU0', 'direction': '南', 'businessarea': [], 'address': '温泉大道886号', 'poiweight': '0.158426', 'name': '中山大学南方学院学术交流中心', 'location': '113.679959,23.630496', 'distance': '241.095', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B0FFLBEOND', 'direction': '东南', 'businessarea': [], 'address': [], 'poiweight': '0.190963', 'name': '聚贤楼10号', 'location': '113.681253,23.631036', 'distance': '263.444', 'tel': [], 'type': '商务住宅;住宅区;宿舍'}, {'id': 'B0FFHJFHVN', 'direction': '北', 'businessarea': [], 'address': '温泉镇温泉大道', 'poiweight': '0.210336', 'name': '中山大学南方学院第五食堂', 'location': '113.679234,23.634647', 'distance': '230.464', 'tel': [], 'type': '餐饮服务;中餐厅;中餐厅'}, {'id': 'B0FFJLW0O9', 'direction': '西', 'businessarea': [], 'address': '博学路4附近', 'poiweight': '0.191645', 'name': '中山大学南方学院西区饭堂', 'location': '113.676210,23.632177', 'distance': '316.572', 'tel': [], 'type': '科教文化服务;科教文化场所;科教文化场所'}, {'id': 'B0FFJBZLYT', 'direction': '西北', 'businessarea': [], 'address': '中山路与博学路交叉口东南50米', 'poiweight': '0.297382', 'name': '铜像广场', 'location': '113.676921,23.634555', 'distance': '326.444', 'tel': [], 'type': '风景名胜;风景名胜;风景名胜'}, {'id': 'B0FFG8CSEK', 'direction': '东', 'businessarea': [], 'address': '温泉镇', 'poiweight': '0.185371', 'name': 'L5员工宿舍', 'location': '113.682583,23.631487', 'distance': '356.923', 'tel': [], 'type': '商务住宅;住宅区;宿舍'}, {'id': 'B0FFKPXO2S', 'direction': '北', 'businessarea': [], 'address': '博学路附近', 'poiweight': '0.188247', 'name': '中山大学南方学院医务室', 'location': '113.679394,23.635924', 'distance': '372.556', 'tel': [], 'type': '医疗保健服务;医疗保健服务场所;医疗保健服务场所'}, {'id': 'B0FFHHLMF8', 'direction': '东北', 'businessarea': [], 'address': '中山大学南方学院明辩路2号第三饭堂', 'poiweight': '0.178935', 'name': '茗语轩餐厅', 'location': '113.681901,23.634495', 'distance': '341.332', 'tel': '13929501395', 'type': '餐饮服务;中餐厅;中餐厅'}, {'id': 'B0FFGXGN3K', 'direction': '东', 'businessarea': [], 'address': [], 'poiweight': '0.188657', 'name': '中山大学南方学院宿舍H25', 'location': '113.683474,23.632020', 'distance': '430.984', 'tel': [], 'type': '商务住宅;住宅区;宿舍'}, {'id': 'B0FFGQ2UG9', 'direction': '东', 'businessarea': [], 'address': '温泉镇', 'poiweight': '0.189884', 'name': 'H23学生宿舍楼', 'location': '113.684021,23.633311', 'distance': '489.185', 'tel': [], 'type': '商务住宅;住宅区;宿舍'}, {'id': 'B0FFGBBC19', 'direction': '东', 'businessarea': [], 'address': '温泉镇', 'poiweight': '0.2587', 'name': '保利桃花源', 'location': '113.685212,23.633333', 'distance': '609.461', 'tel': '020-37918888', 'type': '商务住宅;住宅区;别墅'}, {'id': 'B00140U844', 'direction': '西南', 'businessarea': [], 'address': '博学路24', 'poiweight': '0.203285', 'name': '学生宿舍H-5', 'location': '113.677267,23.629149', 'distance': '433.01', 'tel': [], 'type': '地名地址信息;门牌信息;楼栋号'}, {'id': 'B0FFKQ210C', 'direction': '北', 'businessarea': [], 'address': [], 'poiweight': '0.218258', 'name': '中山大学南方学院聚贤楼7号', 'location': '113.680958,23.636938', 'distance': '514.173', 'tel': [], 'type': '商务住宅;商务住宅相关;商务住宅相关'}, {'id': 'B0FFHVQGBY', 'direction': '南', 'businessarea': [], 'address': [], 'poiweight': '0.170485', 'name': '广州市从化温泉塔洛灯商店', 'location': '113.680212,23.627906', 'distance': '527.663', 'tel': [], 'type': '购物服务;家居建材市场;家居建材市场'}, {'id': 'B0FFLJV95W', 'direction': '东北', 'businessarea': [], 'address': [], 'poiweight': '0.28899', 'name': '中山大学南方学院12BLOCK', 'location': '113.682608,23.636598', 'distance': '560.894', 'tel': [], 'type': '科教文化服务;学校;高等院校'}, {'id': 'B0FFGF9WTH', 'direction': '东北', 'businessarea': [], 'address': '从化区', 'poiweight': '0.196592', 'name': '田螺山隧道', 'location': '113.683736,23.638949', 'distance': '841.305', 'tel': [], 'type': '地名地址信息;交通地名;隧道'}]}, 'info': 'OK', 'infocode': '10000'}\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>status</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>info</th>\n",
       "      <td>OK</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>infocode</th>\n",
       "      <td>10000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.roads</th>\n",
       "      <td>[{'id': '020F49F0050461203', 'location': '113....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.roadinters</th>\n",
       "      <td>[{'second_name': '中山路', 'first_id': '020F49F00...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.formatted_address</th>\n",
       "      <td>广东省广州市从化区温泉镇中山大学南方学院</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.city</th>\n",
       "      <td>广州市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.province</th>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.adcode</th>\n",
       "      <td>440117</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.district</th>\n",
       "      <td>从化区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.towncode</th>\n",
       "      <td>440117103000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.streetNumber.number</th>\n",
       "      <td>7号</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.streetNumber.location</th>\n",
       "      <td>113.6786,23.6333289</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.streetNumber.direction</th>\n",
       "      <td>西北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.streetNumber.distance</th>\n",
       "      <td>109.203</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.streetNumber.street</th>\n",
       "      <td>博学路</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.country</th>\n",
       "      <td>中国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.township</th>\n",
       "      <td>温泉镇</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.businessAreas</th>\n",
       "      <td>[[]]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.building.name</th>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.building.type</th>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.neighborhood.name</th>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.neighborhood.type</th>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.addressComponent.citycode</th>\n",
       "      <td>020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.aois</th>\n",
       "      <td>[{'area': '536585.849985', 'type': '141201', '...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>regeocode.pois</th>\n",
       "      <td>[{'id': 'B00140MR9A', 'direction': '西', 'busin...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                   0\n",
       "status                                                                                             1\n",
       "info                                                                                              OK\n",
       "infocode                                                                                       10000\n",
       "regeocode.roads                                    [{'id': '020F49F0050461203', 'location': '113....\n",
       "regeocode.roadinters                               [{'second_name': '中山路', 'first_id': '020F49F00...\n",
       "regeocode.formatted_address                                                     广东省广州市从化区温泉镇中山大学南方学院\n",
       "regeocode.addressComponent.city                                                                  广州市\n",
       "regeocode.addressComponent.province                                                              广东省\n",
       "regeocode.addressComponent.adcode                                                             440117\n",
       "regeocode.addressComponent.district                                                              从化区\n",
       "regeocode.addressComponent.towncode                                                     440117103000\n",
       "regeocode.addressComponent.streetNumber.number                                                    7号\n",
       "regeocode.addressComponent.streetNumber.location                                 113.6786,23.6333289\n",
       "regeocode.addressComponent.streetNumber.direction                                                 西北\n",
       "regeocode.addressComponent.streetNumber.distance                                             109.203\n",
       "regeocode.addressComponent.streetNumber.street                                                   博学路\n",
       "regeocode.addressComponent.country                                                                中国\n",
       "regeocode.addressComponent.township                                                              温泉镇\n",
       "regeocode.addressComponent.businessAreas                                                        [[]]\n",
       "regeocode.addressComponent.building.name                                                          []\n",
       "regeocode.addressComponent.building.type                                                          []\n",
       "regeocode.addressComponent.neighborhood.name                                                      []\n",
       "regeocode.addressComponent.neighborhood.type                                                      []\n",
       "regeocode.addressComponent.citycode                                                              020\n",
       "regeocode.aois                                     [{'area': '536585.849985', 'type': '141201', '...\n",
       "regeocode.pois                                     [{'id': 'B00140MR9A', 'direction': '西', 'busin..."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def regeocode(location,poitype=None,radius=None,extensions=\"base\",batch=False,roadlevel=None,sig=None,homeorcorp=None)->dict:\n",
    "    \"\"\"获取逆地理编码\"\"\"\n",
    "    url = 'https://restapi.amap.com/v3/geocode/regeo?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'location':中大南方,\n",
    "        'poitype':poitype,\n",
    "        'radius':radius,\n",
    "        'extensions':extensions,\n",
    "        'batch':batch,\n",
    "        'roadlevel':roadlevel,\n",
    "        'homeorcorp':homeorcorp,\n",
    "        'sig':sig,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data\n",
    "\n",
    "中大南方逆地理编码 = regeocode(中大南方)\n",
    "中大南方逆地理编码_all = regeocode(中大南方,extensions=\"all\")\n",
    "print(中大南方逆地理编码_all)\n",
    "df_中大南方逆地理编码_all = pd.json_normalize(中大南方逆地理编码_all).T\n",
    "display(df_中大南方逆地理编码_all)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 路径规划"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "def walking(origin:str,destination:str)->dict:\n",
    "    \"\"\"路径规划\n",
    "    输入起始点和终止点经纬度数据可获取路线规划\n",
    "    可通过geo()函数查询具体地点的经纬度\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'origin':origin,\n",
    "        'destination':destination,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/direction/walking?parameters\",params = parameters)\n",
    "    data = r.json()['route']['paths'][0]['steps']\n",
    "    for i in range(0,len(data)):\n",
    "        print(data[int(i)]['instruction'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "向南步行161米右转\n",
      "向西步行99米左转\n",
      "向南步行237米左转\n",
      "向南步行498米向右前方行走\n",
      "沿源富街向西南步行1568米直行\n",
      "沿源湖街向西步行784米右转\n",
      "沿龙泉路向西北步行1723米向左前方行走\n",
      "沿龙泉路向西步行67米向左前方行走\n",
      "沿温泉大道向西步行22米右转\n",
      "步行13米左转\n",
      "沿温泉大道向西南步行1425米右转\n",
      "向西北步行96米右转\n",
      "向北步行66米到达目的地\n"
     ]
    }
   ],
   "source": [
    "walking(geocodes(\"广东省广州市从化区中山大学南方学院\",\"广州\"),geocodes(\"广东省广州市从化区温泉镇政府\",\"广州\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 行政区域查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>name</th>\n",
       "      <th>center</th>\n",
       "      <th>level</th>\n",
       "      <th>districts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0758</td>\n",
       "      <td>441200</td>\n",
       "      <td>肇庆市</td>\n",
       "      <td>112.472529,23.051546</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0758', 'adcode': '441224', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0757</td>\n",
       "      <td>440600</td>\n",
       "      <td>佛山市</td>\n",
       "      <td>113.122717,23.028762</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0757', 'adcode': '440607', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0754</td>\n",
       "      <td>440500</td>\n",
       "      <td>汕头市</td>\n",
       "      <td>116.708463,23.37102</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0754', 'adcode': '440513', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0752</td>\n",
       "      <td>441300</td>\n",
       "      <td>惠州市</td>\n",
       "      <td>114.412599,23.079404</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0752', 'adcode': '441324', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0755</td>\n",
       "      <td>440300</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>114.085947,22.547</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440306', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0756</td>\n",
       "      <td>440400</td>\n",
       "      <td>珠海市</td>\n",
       "      <td>113.553986,22.224979</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0756', 'adcode': '440402', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0759</td>\n",
       "      <td>440800</td>\n",
       "      <td>湛江市</td>\n",
       "      <td>110.364977,21.274898</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0759', 'adcode': '440883', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0662</td>\n",
       "      <td>441700</td>\n",
       "      <td>阳江市</td>\n",
       "      <td>111.975107,21.859222</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0662', 'adcode': '441781', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0660</td>\n",
       "      <td>441500</td>\n",
       "      <td>汕尾市</td>\n",
       "      <td>115.364238,22.774485</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0660', 'adcode': '441523', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0768</td>\n",
       "      <td>445100</td>\n",
       "      <td>潮州市</td>\n",
       "      <td>116.632301,23.661701</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0768', 'adcode': '445122', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0750</td>\n",
       "      <td>440700</td>\n",
       "      <td>江门市</td>\n",
       "      <td>113.094942,22.590431</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0750', 'adcode': '440784', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>0766</td>\n",
       "      <td>445300</td>\n",
       "      <td>云浮市</td>\n",
       "      <td>112.044439,22.929801</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0766', 'adcode': '445322', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0767</td>\n",
       "      <td>442100</td>\n",
       "      <td>东沙群岛</td>\n",
       "      <td>116.887312,20.617512</td>\n",
       "      <td>city</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>0668</td>\n",
       "      <td>440900</td>\n",
       "      <td>茂名市</td>\n",
       "      <td>110.919229,21.659751</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0668', 'adcode': '440983', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0762</td>\n",
       "      <td>441600</td>\n",
       "      <td>河源市</td>\n",
       "      <td>114.697802,23.746266</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0762', 'adcode': '441622', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0753</td>\n",
       "      <td>441400</td>\n",
       "      <td>梅州市</td>\n",
       "      <td>116.117582,24.299112</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0753', 'adcode': '441427', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0769</td>\n",
       "      <td>441900</td>\n",
       "      <td>东莞市</td>\n",
       "      <td>113.746262,23.046237</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0769', 'adcode': '441900', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0663</td>\n",
       "      <td>445200</td>\n",
       "      <td>揭阳市</td>\n",
       "      <td>116.355733,23.543778</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0663', 'adcode': '445222', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0763</td>\n",
       "      <td>441800</td>\n",
       "      <td>清远市</td>\n",
       "      <td>113.051227,23.685022</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0763', 'adcode': '441882', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>0751</td>\n",
       "      <td>440200</td>\n",
       "      <td>韶关市</td>\n",
       "      <td>113.591544,24.801322</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0751', 'adcode': '440282', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>020</td>\n",
       "      <td>440100</td>\n",
       "      <td>广州市</td>\n",
       "      <td>113.280637,23.125178</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '020', 'adcode': '440117', 'name...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>0760</td>\n",
       "      <td>442000</td>\n",
       "      <td>中山市</td>\n",
       "      <td>113.382391,22.521113</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0760', 'adcode': '442000', 'nam...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   citycode  adcode  name                center level  \\\n",
       "0      0758  441200   肇庆市  112.472529,23.051546  city   \n",
       "1      0757  440600   佛山市  113.122717,23.028762  city   \n",
       "2      0754  440500   汕头市   116.708463,23.37102  city   \n",
       "3      0752  441300   惠州市  114.412599,23.079404  city   \n",
       "4      0755  440300   深圳市     114.085947,22.547  city   \n",
       "5      0756  440400   珠海市  113.553986,22.224979  city   \n",
       "6      0759  440800   湛江市  110.364977,21.274898  city   \n",
       "7      0662  441700   阳江市  111.975107,21.859222  city   \n",
       "8      0660  441500   汕尾市  115.364238,22.774485  city   \n",
       "9      0768  445100   潮州市  116.632301,23.661701  city   \n",
       "10     0750  440700   江门市  113.094942,22.590431  city   \n",
       "11     0766  445300   云浮市  112.044439,22.929801  city   \n",
       "12     0767  442100  东沙群岛  116.887312,20.617512  city   \n",
       "13     0668  440900   茂名市  110.919229,21.659751  city   \n",
       "14     0762  441600   河源市  114.697802,23.746266  city   \n",
       "15     0753  441400   梅州市  116.117582,24.299112  city   \n",
       "16     0769  441900   东莞市  113.746262,23.046237  city   \n",
       "17     0663  445200   揭阳市  116.355733,23.543778  city   \n",
       "18     0763  441800   清远市  113.051227,23.685022  city   \n",
       "19     0751  440200   韶关市  113.591544,24.801322  city   \n",
       "20      020  440100   广州市  113.280637,23.125178  city   \n",
       "21     0760  442000   中山市  113.382391,22.521113  city   \n",
       "\n",
       "                                            districts  \n",
       "0   [{'citycode': '0758', 'adcode': '441224', 'nam...  \n",
       "1   [{'citycode': '0757', 'adcode': '440607', 'nam...  \n",
       "2   [{'citycode': '0754', 'adcode': '440513', 'nam...  \n",
       "3   [{'citycode': '0752', 'adcode': '441324', 'nam...  \n",
       "4   [{'citycode': '0755', 'adcode': '440306', 'nam...  \n",
       "5   [{'citycode': '0756', 'adcode': '440402', 'nam...  \n",
       "6   [{'citycode': '0759', 'adcode': '440883', 'nam...  \n",
       "7   [{'citycode': '0662', 'adcode': '441781', 'nam...  \n",
       "8   [{'citycode': '0660', 'adcode': '441523', 'nam...  \n",
       "9   [{'citycode': '0768', 'adcode': '445122', 'nam...  \n",
       "10  [{'citycode': '0750', 'adcode': '440784', 'nam...  \n",
       "11  [{'citycode': '0766', 'adcode': '445322', 'nam...  \n",
       "12                                                 []  \n",
       "13  [{'citycode': '0668', 'adcode': '440983', 'nam...  \n",
       "14  [{'citycode': '0762', 'adcode': '441622', 'nam...  \n",
       "15  [{'citycode': '0753', 'adcode': '441427', 'nam...  \n",
       "16  [{'citycode': '0769', 'adcode': '441900', 'nam...  \n",
       "17  [{'citycode': '0663', 'adcode': '445222', 'nam...  \n",
       "18  [{'citycode': '0763', 'adcode': '441882', 'nam...  \n",
       "19  [{'citycode': '0751', 'adcode': '440282', 'nam...  \n",
       "20  [{'citycode': '020', 'adcode': '440117', 'name...  \n",
       "21  [{'citycode': '0760', 'adcode': '442000', 'nam...  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def district(keywords,subdistrict=None,page=None,offset=None,extensions='base',filter=None,)->dict:\n",
    "    \"\"\"输入关键词可查询下级行政区域\"\"\"\n",
    "    url = 'https://restapi.amap.com/v3/config/district?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'subdistrict':subdistrict,\n",
    "        'page':page,\n",
    "        'offset':offset,\n",
    "        'extensions':extensions,\n",
    "        'filter':filter,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data\n",
    "行政区域 = district(keywords='广东',extensions='all',subdistrict=3)\n",
    "\n",
    "df_行政区域_1级 = pd.json_normalize(行政区域[\"districts\"][0]['districts'])\n",
    "\n",
    "display(df_行政区域_1级)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>name</th>\n",
       "      <th>center</th>\n",
       "      <th>level</th>\n",
       "      <th>districts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0755</td>\n",
       "      <td>440306</td>\n",
       "      <td>宝安区</td>\n",
       "      <td>113.828671,22.754741</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440306', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0755</td>\n",
       "      <td>440305</td>\n",
       "      <td>南山区</td>\n",
       "      <td>113.92943,22.531221</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440305', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0755</td>\n",
       "      <td>440304</td>\n",
       "      <td>福田区</td>\n",
       "      <td>114.05096,22.541009</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440304', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0755</td>\n",
       "      <td>440308</td>\n",
       "      <td>盐田区</td>\n",
       "      <td>114.235366,22.555069</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440308', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0755</td>\n",
       "      <td>440303</td>\n",
       "      <td>罗湖区</td>\n",
       "      <td>114.123885,22.555341</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440303', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0755</td>\n",
       "      <td>440307</td>\n",
       "      <td>龙岗区</td>\n",
       "      <td>114.251372,22.721511</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440307', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0755</td>\n",
       "      <td>440309</td>\n",
       "      <td>龙华区</td>\n",
       "      <td>114.044346,22.691963</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440309', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0755</td>\n",
       "      <td>440310</td>\n",
       "      <td>坪山区</td>\n",
       "      <td>114.338441,22.69423</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440310', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0755</td>\n",
       "      <td>440311</td>\n",
       "      <td>光明区</td>\n",
       "      <td>113.935895,22.748816</td>\n",
       "      <td>district</td>\n",
       "      <td>[{'citycode': '0755', 'adcode': '440311', 'nam...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  citycode  adcode name                center     level  \\\n",
       "0     0755  440306  宝安区  113.828671,22.754741  district   \n",
       "1     0755  440305  南山区   113.92943,22.531221  district   \n",
       "2     0755  440304  福田区   114.05096,22.541009  district   \n",
       "3     0755  440308  盐田区  114.235366,22.555069  district   \n",
       "4     0755  440303  罗湖区  114.123885,22.555341  district   \n",
       "5     0755  440307  龙岗区  114.251372,22.721511  district   \n",
       "6     0755  440309  龙华区  114.044346,22.691963  district   \n",
       "7     0755  440310  坪山区   114.338441,22.69423  district   \n",
       "8     0755  440311  光明区  113.935895,22.748816  district   \n",
       "\n",
       "                                           districts  \n",
       "0  [{'citycode': '0755', 'adcode': '440306', 'nam...  \n",
       "1  [{'citycode': '0755', 'adcode': '440305', 'nam...  \n",
       "2  [{'citycode': '0755', 'adcode': '440304', 'nam...  \n",
       "3  [{'citycode': '0755', 'adcode': '440308', 'nam...  \n",
       "4  [{'citycode': '0755', 'adcode': '440303', 'nam...  \n",
       "5  [{'citycode': '0755', 'adcode': '440307', 'nam...  \n",
       "6  [{'citycode': '0755', 'adcode': '440309', 'nam...  \n",
       "7  [{'citycode': '0755', 'adcode': '440310', 'nam...  \n",
       "8  [{'citycode': '0755', 'adcode': '440311', 'nam...  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_行政区域_2级_深圳市 = pd.json_normalize(行政区域[\"districts\"][0]['districts'][4]['districts'])\n",
    "display(df_行政区域_2级_深圳市)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# POI搜索之关键字搜索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>parent</th>\n",
       "      <th>childtype</th>\n",
       "      <th>name</th>\n",
       "      <th>tag</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>biz_type</th>\n",
       "      <th>address</th>\n",
       "      <th>location</th>\n",
       "      <th>...</th>\n",
       "      <th>discount_num</th>\n",
       "      <th>event</th>\n",
       "      <th>children</th>\n",
       "      <th>photos</th>\n",
       "      <th>indoor_data.cpid</th>\n",
       "      <th>indoor_data.floor</th>\n",
       "      <th>indoor_data.truefloor</th>\n",
       "      <th>indoor_data.cmsid</th>\n",
       "      <th>biz_ext.rating</th>\n",
       "      <th>biz_ext.cost</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>B0FFF2VPSG</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳南山图书馆设计图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>南山大道3838号设计产业园M栋(绿色)二楼</td>\n",
       "      <td>113.925630,22.547716</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFGITNKT ', 'name': ' 深圳南山图书馆设计图书馆...</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>4.0</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B02F38I801</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳南山图书馆·赤湾分馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>招商街道赤湾六路南开综合楼3层</td>\n",
       "      <td>113.889791,22.480149</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>B0FFG8F2X9</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>简阅书吧(光明店)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>光明街道华夏路群众体育中心</td>\n",
       "      <td>113.947968,22.748076</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': '门面', 'url': 'http://store.is.auton...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>B02F37V7KB</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳市科技图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>西丽镇丽水路深圳大学城西校区</td>\n",
       "      <td>113.973127,22.590351</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFGJ64MA ', 'name': ' 深圳市科技图书馆(东南门...</td>\n",
       "      <td>[{'title': '内景', 'url': 'http://store.is.auton...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>5.0</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>B02F37VHAS</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>福中一路2001号</td>\n",
       "      <td>114.05729,22.545657</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFFZV8Q2 ', 'name': ' 深圳图书馆(北门) ',...</td>\n",
       "      <td>[{'title': '外景图', 'url': 'http://store.is.auto...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>5.0</td>\n",
       "      <td>61.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>B0FFGIB66A</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>南山图书馆(常兴路馆)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>常兴路176-4号</td>\n",
       "      <td>113.921946,22.534875</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFLPKB0B ', 'name': ' 南山图书馆常兴路馆(正门...</td>\n",
       "      <td>[{'title': '内景', 'url': 'http://store.is.auton...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>5.0</td>\n",
       "      <td>22.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>B0FFFEXUO8</td>\n",
       "      <td>B02F37UIGT</td>\n",
       "      <td>309</td>\n",
       "      <td>深圳大学-汇典楼</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>南海大道3688号深圳大学附近</td>\n",
       "      <td>113.935400,22.533186</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>4.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>B0FFHLKYGF</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>横岗图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>龙岗大道横岗段3244号</td>\n",
       "      <td>114.197773,22.641220</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>B02F37WE4F</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>光明街道办事处图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>光明大街100光明影剧院</td>\n",
       "      <td>113.944572,22.763147</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>B02F37W4YV</td>\n",
       "      <td>B02F37UIGT</td>\n",
       "      <td>309</td>\n",
       "      <td>深圳大学-图书馆(南馆)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>南山大道3688号</td>\n",
       "      <td>113.935911,22.53153</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>B0FFHLM7H4</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>龙岗图书馆(微谷分馆)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>坂田贝尔路本丰商务酒店北100米</td>\n",
       "      <td>114.061839,22.641117</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>B0FFH3AH58</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳图书馆城市街区自助图书馆(打石一路)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>打石一路2号附近</td>\n",
       "      <td>113.938057,22.572671</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>B0FFFRKSRT</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>龙华文化艺术中心图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>龙华办事处梅龙路与东环二路交汇处</td>\n",
       "      <td>114.040233,22.654088</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>B02F37VU2D</td>\n",
       "      <td>B02F37SQ4S</td>\n",
       "      <td>302</td>\n",
       "      <td>下沙图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>下沙大道下沙博物馆2层</td>\n",
       "      <td>114.025066,22.526722</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFH4UA5B ', 'name': ' 下沙图书馆停车场 ', ...</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>B02F38PGAA</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>新桥图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>大围六路与新和大道交叉口南100米</td>\n",
       "      <td>113.839311,22.740253</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>B02F37VI5W</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳龙岗图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>龙岗中心城龙城广场东侧龙岗文化中心D区</td>\n",
       "      <td>114.250967,22.719143</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFHGO5AA ', 'name': ' 深圳龙岗图书馆(东门) ...</td>\n",
       "      <td>[{'title': '内景', 'url': 'http://store.is.auton...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>4.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>B02F37UCU0</td>\n",
       "      <td>B02F37WPON</td>\n",
       "      <td>3</td>\n",
       "      <td>福田区图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>景田路70号图书馆大厦</td>\n",
       "      <td>114.045551,22.551078</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFHFLGXV ', 'name': ' 福田区图书馆(南门) '...</td>\n",
       "      <td>[{'title': '休息区', 'url': 'http://store.is.auto...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>5.0</td>\n",
       "      <td>53.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>B0FFGMLBI3</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>甲岸阅读中心</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>新安街道7区宝民一路甲岸村紫岸阁二楼</td>\n",
       "      <td>113.904088,22.561539</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>4.0</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>B0FFH0YFX6</td>\n",
       "      <td>B02F37W58S</td>\n",
       "      <td>202</td>\n",
       "      <td>自助图书馆(098长虹科技大厦)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>科技南十二路18长虹科技大厦1层</td>\n",
       "      <td>113.957749,22.538197</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>B0FFFCOC1K</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>城市街区自助图书馆(空港八道)</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>领航三路GTC地面交通中心2层</td>\n",
       "      <td>113.814029,22.623589</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'title': [], 'url': 'http://store.is.autonav...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>3.5</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>20 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            id      parent childtype                  name tag  \\\n",
       "0   B0FFF2VPSG          []        []          深圳南山图书馆设计图书馆  []   \n",
       "1   B02F38I801          []        []          深圳南山图书馆·赤湾分馆  []   \n",
       "2   B0FFG8F2X9          []        []             简阅书吧(光明店)  []   \n",
       "3   B02F37V7KB          []        []              深圳市科技图书馆  []   \n",
       "4   B02F37VHAS          []        []                 深圳图书馆  []   \n",
       "5   B0FFGIB66A          []        []           南山图书馆(常兴路馆)  []   \n",
       "6   B0FFFEXUO8  B02F37UIGT       309              深圳大学-汇典楼  []   \n",
       "7   B0FFHLKYGF          []        []                 横岗图书馆  []   \n",
       "8   B02F37WE4F          []        []            光明街道办事处图书馆  []   \n",
       "9   B02F37W4YV  B02F37UIGT       309          深圳大学-图书馆(南馆)  []   \n",
       "10  B0FFHLM7H4          []        []           龙岗图书馆(微谷分馆)  []   \n",
       "11  B0FFH3AH58          []        []  深圳图书馆城市街区自助图书馆(打石一路)  []   \n",
       "12  B0FFFRKSRT          []        []           龙华文化艺术中心图书馆  []   \n",
       "13  B02F37VU2D  B02F37SQ4S       302                 下沙图书馆  []   \n",
       "14  B02F38PGAA          []        []                 新桥图书馆  []   \n",
       "15  B02F37VI5W          []        []               深圳龙岗图书馆  []   \n",
       "16  B02F37UCU0  B02F37WPON         3                福田区图书馆  []   \n",
       "17  B0FFGMLBI3          []        []                甲岸阅读中心  []   \n",
       "18  B0FFH0YFX6  B02F37W58S       202      自助图书馆(098长虹科技大厦)  []   \n",
       "19  B0FFFCOC1K          []        []       城市街区自助图书馆(空港八道)  []   \n",
       "\n",
       "              type typecode biz_type                 address  \\\n",
       "0   科教文化服务;图书馆;图书馆   140500       []  南山大道3838号设计产业园M栋(绿色)二楼   \n",
       "1   科教文化服务;图书馆;图书馆   140500       []         招商街道赤湾六路南开综合楼3层   \n",
       "2   科教文化服务;图书馆;图书馆   140500       []           光明街道华夏路群众体育中心   \n",
       "3   科教文化服务;图书馆;图书馆   140500       []          西丽镇丽水路深圳大学城西校区   \n",
       "4   科教文化服务;图书馆;图书馆   140500       []               福中一路2001号   \n",
       "5   科教文化服务;图书馆;图书馆   140500       []               常兴路176-4号   \n",
       "6   科教文化服务;图书馆;图书馆   140500       []         南海大道3688号深圳大学附近   \n",
       "7   科教文化服务;图书馆;图书馆   140500       []            龙岗大道横岗段3244号   \n",
       "8   科教文化服务;图书馆;图书馆   140500       []            光明大街100光明影剧院   \n",
       "9   科教文化服务;图书馆;图书馆   140500       []               南山大道3688号   \n",
       "10  科教文化服务;图书馆;图书馆   140500       []        坂田贝尔路本丰商务酒店北100米   \n",
       "11  科教文化服务;图书馆;图书馆   140500       []                打石一路2号附近   \n",
       "12  科教文化服务;图书馆;图书馆   140500       []        龙华办事处梅龙路与东环二路交汇处   \n",
       "13  科教文化服务;图书馆;图书馆   140500       []             下沙大道下沙博物馆2层   \n",
       "14  科教文化服务;图书馆;图书馆   140500       []       大围六路与新和大道交叉口南100米   \n",
       "15  科教文化服务;图书馆;图书馆   140500       []     龙岗中心城龙城广场东侧龙岗文化中心D区   \n",
       "16  科教文化服务;图书馆;图书馆   140500       []             景田路70号图书馆大厦   \n",
       "17  科教文化服务;图书馆;图书馆   140500       []      新安街道7区宝民一路甲岸村紫岸阁二楼   \n",
       "18  科教文化服务;图书馆;图书馆   140500       []        科技南十二路18长虹科技大厦1层   \n",
       "19  科教文化服务;图书馆;图书馆   140500       []         领航三路GTC地面交通中心2层   \n",
       "\n",
       "                location  ... discount_num event  \\\n",
       "0   113.925630,22.547716  ...            0    []   \n",
       "1   113.889791,22.480149  ...            0    []   \n",
       "2   113.947968,22.748076  ...            0    []   \n",
       "3   113.973127,22.590351  ...            0    []   \n",
       "4    114.05729,22.545657  ...            0    []   \n",
       "5   113.921946,22.534875  ...            0    []   \n",
       "6   113.935400,22.533186  ...            0    []   \n",
       "7   114.197773,22.641220  ...            0    []   \n",
       "8   113.944572,22.763147  ...            0    []   \n",
       "9    113.935911,22.53153  ...            0    []   \n",
       "10  114.061839,22.641117  ...            0    []   \n",
       "11  113.938057,22.572671  ...            0    []   \n",
       "12  114.040233,22.654088  ...            0    []   \n",
       "13  114.025066,22.526722  ...            0    []   \n",
       "14  113.839311,22.740253  ...            0    []   \n",
       "15  114.250967,22.719143  ...            0    []   \n",
       "16  114.045551,22.551078  ...            0    []   \n",
       "17  113.904088,22.561539  ...            0    []   \n",
       "18  113.957749,22.538197  ...            0    []   \n",
       "19  113.814029,22.623589  ...            0    []   \n",
       "\n",
       "                                             children  \\\n",
       "0   [{'id': ' B0FFGITNKT ', 'name': ' 深圳南山图书馆设计图书馆...   \n",
       "1                                                  []   \n",
       "2                                                  []   \n",
       "3   [{'id': ' B0FFGJ64MA ', 'name': ' 深圳市科技图书馆(东南门...   \n",
       "4   [{'id': ' B0FFFZV8Q2 ', 'name': ' 深圳图书馆(北门) ',...   \n",
       "5   [{'id': ' B0FFLPKB0B ', 'name': ' 南山图书馆常兴路馆(正门...   \n",
       "6                                                  []   \n",
       "7                                                  []   \n",
       "8                                                  []   \n",
       "9                                                  []   \n",
       "10                                                 []   \n",
       "11                                                 []   \n",
       "12                                                 []   \n",
       "13  [{'id': ' B0FFH4UA5B ', 'name': ' 下沙图书馆停车场 ', ...   \n",
       "14                                                 []   \n",
       "15  [{'id': ' B0FFHGO5AA ', 'name': ' 深圳龙岗图书馆(东门) ...   \n",
       "16  [{'id': ' B0FFHFLGXV ', 'name': ' 福田区图书馆(南门) '...   \n",
       "17                                                 []   \n",
       "18                                                 []   \n",
       "19                                                 []   \n",
       "\n",
       "                                               photos indoor_data.cpid  \\\n",
       "0   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "1   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "2   [{'title': '门面', 'url': 'http://store.is.auton...               []   \n",
       "3   [{'title': '内景', 'url': 'http://store.is.auton...               []   \n",
       "4   [{'title': '外景图', 'url': 'http://store.is.auto...               []   \n",
       "5   [{'title': '内景', 'url': 'http://store.is.auton...               []   \n",
       "6   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "7   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "8   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "9   [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "10  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "11  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "12  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "13  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "14  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "15  [{'title': '内景', 'url': 'http://store.is.auton...               []   \n",
       "16  [{'title': '休息区', 'url': 'http://store.is.auto...               []   \n",
       "17  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "18  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "19  [{'title': [], 'url': 'http://store.is.autonav...               []   \n",
       "\n",
       "   indoor_data.floor indoor_data.truefloor indoor_data.cmsid biz_ext.rating  \\\n",
       "0                 []                    []                []            4.0   \n",
       "1                 []                    []                []            3.5   \n",
       "2                 []                    []                []            3.5   \n",
       "3                 []                    []                []            5.0   \n",
       "4                 []                    []                []            5.0   \n",
       "5                 []                    []                []            5.0   \n",
       "6                 []                    []                []            4.5   \n",
       "7                 []                    []                []            3.5   \n",
       "8                 []                    []                []            3.5   \n",
       "9                 []                    []                []            3.5   \n",
       "10                []                    []                []            3.5   \n",
       "11                []                    []                []            3.5   \n",
       "12                []                    []                []            3.5   \n",
       "13                []                    []                []            3.5   \n",
       "14                []                    []                []            3.5   \n",
       "15                []                    []                []            4.5   \n",
       "16                []                    []                []            5.0   \n",
       "17                []                    []                []            4.0   \n",
       "18                []                    []                []            3.5   \n",
       "19                []                    []                []            3.5   \n",
       "\n",
       "   biz_ext.cost  \n",
       "0            []  \n",
       "1            []  \n",
       "2            []  \n",
       "3            []  \n",
       "4         61.00  \n",
       "5         22.00  \n",
       "6            []  \n",
       "7            []  \n",
       "8            []  \n",
       "9            []  \n",
       "10           []  \n",
       "11           []  \n",
       "12           []  \n",
       "13           []  \n",
       "14           []  \n",
       "15           []  \n",
       "16        53.00  \n",
       "17           []  \n",
       "18           []  \n",
       "19           []  \n",
       "\n",
       "[20 rows x 46 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def poi(keywords,types,city=None,citylimit=None,children=None,page=None,extensions='base',sig=None)->dict:\n",
    "    \"\"\"输入poi表中的分类、城市查询关键词信息\"\"\"\n",
    "    url = 'https://restapi.amap.com/v3/place/text?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'types':types,\n",
    "        'city':city,\n",
    "        'citylimit':citylimit,\n",
    "        'children':children,\n",
    "        'page':page,\n",
    "        'extensions':extensions,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data\n",
    "\n",
    "深圳_图书馆 = poi('图书馆','图书馆',city=\"深圳市\",children=1,extensions='all')\n",
    "深圳_图书馆\n",
    "df_深圳_图书馆 = pd.json_normalize(深圳_图书馆[\"pois\"])\n",
    "display(df_深圳_图书馆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>parent</th>\n",
       "      <th>childtype</th>\n",
       "      <th>name</th>\n",
       "      <th>tag</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>biz_type</th>\n",
       "      <th>address</th>\n",
       "      <th>location</th>\n",
       "      <th>...</th>\n",
       "      <th>discount_num</th>\n",
       "      <th>event</th>\n",
       "      <th>children</th>\n",
       "      <th>photos</th>\n",
       "      <th>indoor_data.cpid</th>\n",
       "      <th>indoor_data.floor</th>\n",
       "      <th>indoor_data.truefloor</th>\n",
       "      <th>indoor_data.cmsid</th>\n",
       "      <th>biz_ext.rating</th>\n",
       "      <th>biz_ext.cost</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>B02F37VHAS</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>深圳图书馆</td>\n",
       "      <td>[]</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>140500</td>\n",
       "      <td>[]</td>\n",
       "      <td>福中一路2001号</td>\n",
       "      <td>114.05729,22.545657</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'id': ' B0FFFZV8Q2 ', 'name': ' 深圳图书馆(北门) ',...</td>\n",
       "      <td>[{'title': '外景图', 'url': 'http://store.is.auto...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>5.0</td>\n",
       "      <td>61.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 46 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           id parent childtype   name tag            type typecode biz_type  \\\n",
       "0  B02F37VHAS     []        []  深圳图书馆  []  科教文化服务;图书馆;图书馆   140500       []   \n",
       "\n",
       "     address             location  ... discount_num event  \\\n",
       "0  福中一路2001号  114.05729,22.545657  ...            0    []   \n",
       "\n",
       "                                            children  \\\n",
       "0  [{'id': ' B0FFFZV8Q2 ', 'name': ' 深圳图书馆(北门) ',...   \n",
       "\n",
       "                                              photos indoor_data.cpid  \\\n",
       "0  [{'title': '外景图', 'url': 'http://store.is.auto...               []   \n",
       "\n",
       "  indoor_data.floor indoor_data.truefloor indoor_data.cmsid biz_ext.rating  \\\n",
       "0                []                    []                []            5.0   \n",
       "\n",
       "  biz_ext.cost  \n",
       "0        61.00  \n",
       "\n",
       "[1 rows x 46 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 看具体某个图书馆\n",
    "#df_深圳_图书馆 = pd.json_normalize(深圳_图书馆[\"pois\"])\n",
    "df_深圳_图书馆_深圳图书馆 = pd.json_normalize(深圳_图书馆[\"pois\"][4])\n",
    "display(df_深圳_图书馆_深圳图书馆)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# IP定位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ip(ip:str):\n",
    "    \"\"\"IP定位可以帮你定位ip的所在位置，输入对应ip即可\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'ip':ip,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/ip?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    del data['status']\n",
    "    del data['info']\n",
    "    df = [\"省份：%s\"%(data['province']),\"地区：%s\"%(data['city']),\"地理编码：%s\"%(data['adcode']),\"经纬度： %s\"%(data['rectangle'])]\n",
    "    print(\"ip:\"+ip)\n",
    "    for i in df:\n",
    "        print(i)\n",
    "    return    \n",
    "    \n",
    "   \n",
    "   \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ip:120.78.163.166\n",
      "省份：浙江省\n",
      "地区：杭州市\n",
      "地理编码：330100\n",
      "经纬度： 119.8824799,29.95931271;120.5552208,30.52048536\n"
     ]
    }
   ],
   "source": [
    "ip(\"120.78.163.166\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 静态地图 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.image as mpimg\n",
    "import numpy as np\n",
    "def map(location:str,zoom:str):\n",
    "    \"\"\"zoom：设置地图缩放\n",
    "       location：选择地图中心坐标\n",
    "    \"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'location':location,\n",
    "        'zoom':zoom,\n",
    "        \n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/staticmap?parameters\", params=parameters)\n",
    "    data = r.url\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://restapi.amap.com/v3/staticmap?parameters&key=00837098d93ef635613eebd34c533c33&location=113.925762%2C22.511996&zoom=4'"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map(geocodes(\"广东省深圳市南山区来福士广场\",\"深圳\"),4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 坐标转换，将非高德坐标转换为高德坐标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "def assistant(locations:str,coordsys:str):\n",
    "    \"\"\"坐标转换\n",
    "    locations填入非高德坐标\n",
    "    coordsys可选值：gps,mapbar,baidu,autonavi（不进行转换）\n",
    "    \"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'coordsys':coordsys,\n",
    "        'locations':locations,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/assistant/coordinate/convert?parameters\", params=parameters)\n",
    "    data = r.json()['locations']\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'116.487585177952,39.991754014757;116.487585177952,39.991653917101'"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "assistant(\"116.481499,39.990475|116.481499,39.990375\",'gps')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 查询当地当前天气信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "def weather(city:str):\n",
    "    \"\"\"天气查询\n",
    "    查询当地天气情况\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'city':city,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/weather/weatherInfo?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    \n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'lives': [{'province': '广东',\n",
       "   'city': '深圳市',\n",
       "   'adcode': '440300',\n",
       "   'weather': '雨',\n",
       "   'temperature': '20',\n",
       "   'winddirection': '东北',\n",
       "   'windpower': '≤3',\n",
       "   'humidity': '92',\n",
       "   'reporttime': '2020-04-23 15:22:35'}]}"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weather('深圳')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 输入提示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "def inputtips(keywords:str):\n",
    "    \"\"\"填写关键词查询\"\"\"\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get (\"https://restapi.amap.com/v3/assistant/inputtips?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '6',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'tips': [{'id': 'B0FFF2VMJ4',\n",
       "   'name': '中山大学南方学院-综合楼',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.680117,23.631544',\n",
       "   'address': '温泉大道886号中山大学南方学院内',\n",
       "   'typecode': '141200',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFM4JIF8',\n",
       "   'name': '中山大学南方学院达人书院',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.679041,23.632392',\n",
       "   'address': '温泉大道882号中山大学南方学院新综合楼二楼',\n",
       "   'typecode': '140000',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFJHKOFI',\n",
       "   'name': '中山南方物流中心',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.677703,23.629123',\n",
       "   'address': '温泉镇温泉大道882号中山大学南方学院西区综合楼菜鸟驿站',\n",
       "   'typecode': '070500',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFJL1OL7',\n",
       "   'name': '菜鸟驿站(综合物流服务中心)',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.680201,23.631424',\n",
       "   'address': '温泉大道886号中山大学南方学院内中山大学南方学院-综合楼附近',\n",
       "   'typecode': '070500',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFF2LF4P',\n",
       "   'name': '沃佳乐超市',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.679719,23.634633',\n",
       "   'address': '中山大学南方学院中区饭堂二楼',\n",
       "   'typecode': '060400',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFKPZMKM',\n",
       "   'name': '叫了只炸鸡(中山大学店)',\n",
       "   'district': '广东省广州市从化区',\n",
       "   'adcode': '440117',\n",
       "   'location': '113.679286,23.632573',\n",
       "   'address': '温泉镇中山大学南方学院后门润泰超市一楼05号商铺',\n",
       "   'typecode': '050201',\n",
       "   'city': []}]}"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inputtips(\"中山大学南方学院综合楼\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#  交通态势\n",
    "#### - 目前支持城市：北京，上海，广州，深圳，宁波，武汉，重庆，成都，沈阳，南京，杭州，长春，常州，大连，东莞，福州，青岛，石家庄，天津，太原，西安，无锡，厦门，珠海，长沙，苏州，金华，佛山，济南，泉州，嘉兴，西宁，惠州，温州，中山，合肥，乌鲁木齐，台州，绍兴，昆明。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'trafficinfo': {'description': '南山大道：双向畅通。',\n",
       "  'evaluation': {'expedite': '100.00%',\n",
       "   'congested': '0.00%',\n",
       "   'blocked': '0.00%',\n",
       "   'unknown': '0.00%',\n",
       "   'status': '1',\n",
       "   'description': '畅通'}}}"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def road(name,city,level=None,extensions=None,sig=None)->dict:\n",
    "    \"\"\"road内输入道路，城市\"\"\"\n",
    "    url = 'https://restapi.amap.com/v3/traffic/status/road?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'name':name,\n",
    "        'city':city,\n",
    "        'level':level,\n",
    "        'extensions':extensions,\n",
    "        'sig':sig,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data\n",
    "交通态势 = road( '南山大道', '深圳')\n",
    "交通态势"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'trafficinfo': {'description': '莲花路：双向畅通。',\n",
       "  'evaluation': {'expedite': '100.00%',\n",
       "   'congested': '0.00%',\n",
       "   'blocked': '0.00%',\n",
       "   'unknown': '0.00%',\n",
       "   'status': '1',\n",
       "   'description': '畅通'}}}"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "road(\"莲花路\",\"上海\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 批量请求"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>typecode</th>\n",
       "      <th>adname</th>\n",
       "      <th>id</th>\n",
       "      <th>pname</th>\n",
       "      <th>parent</th>\n",
       "      <th>location</th>\n",
       "      <th>distance</th>\n",
       "      <th>address</th>\n",
       "      <th>cityname</th>\n",
       "      <th>type</th>\n",
       "      <th>shopinfo</th>\n",
       "      <th>name</th>\n",
       "      <th>childtype</th>\n",
       "      <th>biz_ext.rating</th>\n",
       "      <th>photos</th>\n",
       "      <th>biz_ext.seat_ordering</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>080105</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFF4WQPK</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.291511,23.201070</td>\n",
       "      <td>117</td>\n",
       "      <td>云溪东路与云溪五路交叉口东100米</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;运动场馆;足球场</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学(北校区)-足球场</td>\n",
       "      <td>309</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>080100</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFF4UFRZ</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.291510,23.201069</td>\n",
       "      <td>117</td>\n",
       "      <td>广东外语外贸大学校内</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;运动场馆;运动场所</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学田径场</td>\n",
       "      <td>309</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>080112</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFHK55NE</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.293368,23.203826</td>\n",
       "      <td>389</td>\n",
       "      <td>白云大道北2号</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;运动场馆;乒乓球馆</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学(北校区)-乒乓球室</td>\n",
       "      <td>309</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>141201|080500</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFG8PXI1</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.296635,23.199263</td>\n",
       "      <td>449</td>\n",
       "      <td>白云大道北2号</td>\n",
       "      <td>广州市</td>\n",
       "      <td>科教文化服务;学校;高等院校|体育休闲服务;休闲场所;休闲场所</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学教工活动中心</td>\n",
       "      <td>309</td>\n",
       "      <td>3.5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>080101</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFGJAVXI</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.293161,23.204464</td>\n",
       "      <td>454</td>\n",
       "      <td>白云大道北2号</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;运动场馆;综合体育馆</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学北校区体育馆</td>\n",
       "      <td>309</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>080110</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFHJI70H</td>\n",
       "      <td>广东省</td>\n",
       "      <td>B00140WEMJ</td>\n",
       "      <td>113.295014,23.204705</td>\n",
       "      <td>543</td>\n",
       "      <td>白云大道北2号</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;运动场馆;游泳馆</td>\n",
       "      <td>0</td>\n",
       "      <td>广东外语外贸大学(北校区)-游泳场</td>\n",
       "      <td>309</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>080000</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFK55YZN</td>\n",
       "      <td>广东省</td>\n",
       "      <td>NaN</td>\n",
       "      <td>113.294557,23.205185</td>\n",
       "      <td>571</td>\n",
       "      <td>NaN</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;体育休闲服务场所;体育休闲服务场所</td>\n",
       "      <td>0</td>\n",
       "      <td>奥云山体育俱乐部</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>080603</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFHWXLEA</td>\n",
       "      <td>广东省</td>\n",
       "      <td>NaN</td>\n",
       "      <td>113.287411,23.202847</td>\n",
       "      <td>579</td>\n",
       "      <td>白云大道北47号附近</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;影剧院;剧场</td>\n",
       "      <td>0</td>\n",
       "      <td>顶尖人演艺大厅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>080000</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFM4VDRG</td>\n",
       "      <td>广东省</td>\n",
       "      <td>NaN</td>\n",
       "      <td>113.295608,23.204909</td>\n",
       "      <td>594</td>\n",
       "      <td>丛云路68号云山会馆5号楼</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;体育休闲服务场所;体育休闲服务场所</td>\n",
       "      <td>0</td>\n",
       "      <td>今令企业家俱乐部</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>080304</td>\n",
       "      <td>白云区</td>\n",
       "      <td>B0FFFA79RW</td>\n",
       "      <td>广东省</td>\n",
       "      <td>NaN</td>\n",
       "      <td>113.295839,23.204800</td>\n",
       "      <td>597</td>\n",
       "      <td>云山会馆</td>\n",
       "      <td>广州市</td>\n",
       "      <td>体育休闲服务;娱乐场所;酒吧</td>\n",
       "      <td>0</td>\n",
       "      <td>冰玲珑品酒私厨汇</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        typecode adname          id pname      parent              location  \\\n",
       "0         080105    白云区  B0FFF4WQPK   广东省  B00140WEMJ  113.291511,23.201070   \n",
       "1         080100    白云区  B0FFF4UFRZ   广东省  B00140WEMJ  113.291510,23.201069   \n",
       "2         080112    白云区  B0FFHK55NE   广东省  B00140WEMJ  113.293368,23.203826   \n",
       "3  141201|080500    白云区  B0FFG8PXI1   广东省  B00140WEMJ  113.296635,23.199263   \n",
       "4         080101    白云区  B0FFGJAVXI   广东省  B00140WEMJ  113.293161,23.204464   \n",
       "5         080110    白云区  B0FFHJI70H   广东省  B00140WEMJ  113.295014,23.204705   \n",
       "6         080000    白云区  B0FFK55YZN   广东省         NaN  113.294557,23.205185   \n",
       "7         080603    白云区  B0FFHWXLEA   广东省         NaN  113.287411,23.202847   \n",
       "8         080000    白云区  B0FFM4VDRG   广东省         NaN  113.295608,23.204909   \n",
       "9         080304    白云区  B0FFFA79RW   广东省         NaN  113.295839,23.204800   \n",
       "\n",
       "  distance            address cityname                             type  \\\n",
       "0      117  云溪东路与云溪五路交叉口东100米      广州市                  体育休闲服务;运动场馆;足球场   \n",
       "1      117         广东外语外贸大学校内      广州市                 体育休闲服务;运动场馆;运动场所   \n",
       "2      389            白云大道北2号      广州市                 体育休闲服务;运动场馆;乒乓球馆   \n",
       "3      449            白云大道北2号      广州市  科教文化服务;学校;高等院校|体育休闲服务;休闲场所;休闲场所   \n",
       "4      454            白云大道北2号      广州市                体育休闲服务;运动场馆;综合体育馆   \n",
       "5      543            白云大道北2号      广州市                  体育休闲服务;运动场馆;游泳馆   \n",
       "6      571                NaN      广州市         体育休闲服务;体育休闲服务场所;体育休闲服务场所   \n",
       "7      579         白云大道北47号附近      广州市                    体育休闲服务;影剧院;剧场   \n",
       "8      594      丛云路68号云山会馆5号楼      广州市         体育休闲服务;体育休闲服务场所;体育休闲服务场所   \n",
       "9      597               云山会馆      广州市                   体育休闲服务;娱乐场所;酒吧   \n",
       "\n",
       "  shopinfo                name childtype biz_ext.rating  \\\n",
       "0        0   广东外语外贸大学(北校区)-足球场       309            NaN   \n",
       "1        0         广东外语外贸大学田径场       309            NaN   \n",
       "2        0  广东外语外贸大学(北校区)-乒乓球室       309            NaN   \n",
       "3        0      广东外语外贸大学教工活动中心       309            3.5   \n",
       "4        0      广东外语外贸大学北校区体育馆       309            NaN   \n",
       "5        0   广东外语外贸大学(北校区)-游泳场       309            NaN   \n",
       "6        0            奥云山体育俱乐部       NaN            NaN   \n",
       "7        0             顶尖人演艺大厅       NaN            NaN   \n",
       "8        0            今令企业家俱乐部       NaN            NaN   \n",
       "9        0            冰玲珑品酒私厨汇       NaN            NaN   \n",
       "\n",
       "                                              photos biz_ext.seat_ordering  \n",
       "0                                                NaN                   NaN  \n",
       "1                                                NaN                   NaN  \n",
       "2                                                NaN                   NaN  \n",
       "3                                                NaN                   NaN  \n",
       "4                                                NaN                   NaN  \n",
       "5                                                NaN                   NaN  \n",
       "6                                                NaN                   NaN  \n",
       "7  [{'url': 'http://store.is.autonavi.com/showpic...                     0  \n",
       "8                                                NaN                   NaN  \n",
       "9                                                NaN                   NaN  "
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import json\n",
    "def batch():\n",
    "    url = 'https://restapi.amap.com/v3/batch?key=14dc3151f80e56462d23f40d60cfa779'\n",
    "    headers = {\n",
    "        \"content-type\":\"application/json\"\n",
    "    }  \n",
    "    body = {\n",
    "      \"ops\": [\n",
    "        {\n",
    "            \"url\": \"/v3/place/around?offset=10&page=1&key=14dc3151f80e56462d23f40d60cfa779&location=113.292429,23.200438&output=json&radius=100000&types=080000\"\n",
    "        },\n",
    "        {\n",
    "            \"url\": \"/v3/place/around?offset=10&page=1&key=14dc3151f80e56462d23f40d60cfa779&location=113.679287,23.632575&output=json&radius=100000&types=080000\"\n",
    "        }\n",
    "        ]\n",
    "      }\n",
    "    response = requests.post(url,data = json.dumps(body),headers=headers)\n",
    "    data = response.json()\n",
    "    return data \n",
    "result = batch()\n",
    "df = pd.json_normalize(result[0]['body']['pois'])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 地理围栏"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': {'gid': 'efeaec12-72c9-4381-b9f5-afcbe33cdd71',\n",
       "  'id': '0',\n",
       "  'message': '成功',\n",
       "  'status': '0'},\n",
       " 'errcode': 0,\n",
       " 'errdetail': None,\n",
       " 'errmsg': 'OK',\n",
       " 'ext': None}"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def diliweilan(name=\"测试围栏名称\",center=\"115.672126,38.817129\",radius=None,enable=None,valid_time=None,repeat=None,time=None,desc= \"测试围栏描述\",alert_condition=None)->dict:\n",
    " parameters = {\n",
    "        \"key\":key,\n",
    "    }\n",
    " body = {\n",
    "             \"name\": \"测试围栏名称\",\n",
    "             \"center\": \"115.672126,38.817129\",\n",
    "             \"radius\": \"1000\",\n",
    "             \"enable\": \"true\",\n",
    "             \"valid_time\": \"2020-09-19\",\n",
    "             \"repeat\": \"Mon,Tues,Wed,Thur,Fri,Sat,Sun\",\n",
    "             \"time\": \"00:00,11:59;13:00,20:59\",\n",
    "             \"desc\": \"测试围栏描述\",\n",
    "             \"alert_condition\": \"enter;leave\"\n",
    "}\n",
    " r = requests.post(\"https://restapi.amap.com/v4/geofence/meta?key=\"+key,params=parameters,json=body)\n",
    " data = r.json()\n",
    " return data\n",
    "地理围栏 = diliweilan(center=\"115.672126,38.817129\")\n",
    "地理围栏"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 轨迹纠偏 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data': {'distance': 33.0,\n",
       "  'points': [{'x': 116.44942000249563, 'y': 40.014843356125866},\n",
       "   {'x': 116.44945705955585, 'y': 40.01453960973057}]},\n",
       " 'errcode': 0,\n",
       " 'errdetail': None,\n",
       " 'errmsg': 'OK',\n",
       " 'ext': None}"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def guiji(x=None,y=None,sp=None,ag=None,tm=None)->dict:\n",
    " parameters = {\n",
    "    \"key\":key,\n",
    "}\n",
    " body = [{\n",
    "\"x\": 116.449429,\n",
    "\"y\": 40.014844,\n",
    "\"sp\": 4,\n",
    "\"ag\": 110,\n",
    "\"tm\": 1478831753\n",
    "}, {\n",
    "\"x\": 116.449639,\n",
    "\"y\": 40.014776,\n",
    "\"sp\": 3,\n",
    "\"ag\": 110,\n",
    "\"tm\": 23\n",
    "}, {\n",
    "\"x\": 116.449859,\n",
    "\"y\": 40.014716,\n",
    "\"sp\": 3,\n",
    "\"ag\": 111,\n",
    "\"tm\": 33\n",
    "}, {\n",
    "\"x\": 116.450074,\n",
    "\"y\": 40.014658,\n",
    "\"sp\": 3,\n",
    "\"ag\": 110,\n",
    "\"tm\": 31\n",
    "}, {\n",
    "\"x\": 116.450273,\n",
    "\"y\": 40.014598,\n",
    "\"sp\": 3,\n",
    "\"ag\": 111,\n",
    "\"tm\": 20\n",
    "}]\n",
    " r = requests.post(\"https://restapi.amap.com/v4/grasproad/driving\",params=parameters,json=body)\n",
    " data = r.json()\n",
    " return data\n",
    "轨迹纠偏 = guiji(x=\"116.449639\",y=\"40.014844\",sp=\"4\",ag=\"110\",tm=\"31\")\n",
    "轨迹纠偏"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# API调用的思考\n",
    "1. 路径规划用到了推荐算法\n",
    "2. 输入提示用到了推荐算法\n",
    "3. 静态地图用到了计算机视觉"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 设计一个简单的应用\n",
    "\n",
    "## 校园代购小程序\n",
    "\n",
    "> 为了方便同学们购买生活用品，节约同学们的时间，设计一个怎样的小程序来帮到大家呢？\n",
    "1. 刷脸支付，更快更安全。\n",
    "利用人脸识别技术，让你在下单时更加方便快捷。（人脸识别API）\n",
    "2. 想知道骑手离你还有多远？\n",
    "利用路径规划api，可以让你在手机上看到外卖小哥距你还有多远。（路径规划API）\n",
    "3. 想买的东西怕买错？\n",
    "利用计算机视觉、图像识别API，将实时拍摄的商品照片进行分析，可以准确购买商品。（计算机视觉、图像识别API）"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
